package com.hyj.shop.project.goods.service.impl;

import com.hyj.shop.project.goods.domain.GoodsSpe;
import com.hyj.shop.project.utils.domain.AjaxResult;
import com.hyj.shop.project.utils.domain.Msg;
import com.hyj.shop.project.goods.domain.GoodsInfo;
import com.hyj.shop.project.goods.domain.GoodsInfoImg;
import com.hyj.shop.project.goods.mapper.GoodsInfoMapper;
import com.hyj.shop.project.goods.service.GoodsInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class GoodsInfoServiceImpl implements GoodsInfoService {
    @Autowired
    private GoodsInfoMapper goodsInfoMapper;
    @Override
    public Msg queryGoodsInfo(int goodsId) {
        GoodsInfo goodsInfo=goodsInfoMapper.queryGoodsInfo(goodsId);
        GoodsInfoImg goodsInfoImg=goodsInfoMapper.queryGoodsInfoImg(goodsId);
        List list = new ArrayList();
        list.add(goodsInfo);
        list.add(goodsInfoImg);
        Msg msg = new Msg();
        msg.setData(list);
        msg.setCode(200);
        msg.setStatus("success");
        return msg;
    }

    @Override
    public AjaxResult queryGoodsSpeInfo(String goodsSpe,int goodsId) {
        GoodsSpe data=goodsInfoMapper.queryGoodsSpeInfo(goodsSpe,goodsId);
        AjaxResult ajaxResult=AjaxResult.success("操作成功");
        ajaxResult.put("code",200);
        ajaxResult.put("data",data);
        ajaxResult.put("message","success");
        return ajaxResult;
    }

    @Override
    public AjaxResult queryGoodsInfoImgs(int goodsId) {
        List<GoodsInfoImg> list=goodsInfoMapper.queryGoodsInfoImgs(goodsId);
        AjaxResult ajaxResult=AjaxResult.success("操作成功");
        ajaxResult.put("code",200);
        ajaxResult.put("data",list);
        ajaxResult.put("message","success");
        return ajaxResult;
    }


}
